import { getNetworkEmpPageSelect } from '@/api/network'
import { NetworkEmpOptional } from '@/components/pages/order/list/assign-network/types'
import { ref } from 'vue'

// 获取分配人员选项加载
const getNetworkEmpOptionsLoading = ref(false)

// 分配人员选项
const networkEmpOptions = ref<Array<NetworkEmpOptional>>([])

/**
 * 获取分配人员下拉选项方法
 * @param {string} newNetwork - 新的的部门
 */
const getNetworkEmpOptions = async (newNetworkId: string, keyword = '') => {
  getNetworkEmpOptionsLoading.value = true
  const res = await getNetworkEmpPageSelect(
    {
      limit: 0,
      name: keyword,
      page: 0,
    },
    newNetworkId,
  )
  networkEmpOptions.value = res.data.success ? res.data.data.rows : []
  getNetworkEmpOptionsLoading.value = false
}

export default {
  networkEmpOptions,
  getNetworkEmpOptionsLoading,
  getNetworkEmpOptions,
}
